package com.jaws.demo.apollo;

import lombok.extern.slf4j.Slf4j;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import com.ctrip.framework.apollo.model.ConfigChange;
import com.ctrip.framework.apollo.model.ConfigChangeEvent;
import com.ctrip.framework.apollo.spring.annotation.ApolloConfigChangeListener;

@Component
@Slf4j
public class ApolloCompoment {
	
	@Value("${yjs.jaws.log.size}")
	private String test;
	
	@ApolloConfigChangeListener("job")
	private void onChange(ConfigChangeEvent changeEvent){
		for (String key : changeEvent.changedKeys()) {
            ConfigChange change = changeEvent.getChange(key);
            log.info(String.format(
                "change - key: %s, namespace:%s, oldValue: %s, newValue: %s, changeType: %s",
                change.getNamespace(),
                change.getPropertyName(), change.getOldValue(),
                change.getNewValue(), change.getChangeType()));
        }

	}

}
